/**
 * @name 可复用的方法
 */
 import Vue from "vue";
import { Message } from "element-ui";
//中断请求
export function clearHttpRequestingList() {
  // 判断是否有存储的cancle
  if (Vue.$httpRequestList.length > 0) {
    Vue.$httpRequestList.forEach((item) => {
      // 给个标志，中断请求
      item("interrupt");
    });
    Vue.$httpRequestList = [];
  }
}

//键盘事件
export function amendsortKeyupSet(i, list, that) {
  if (i > -1 && i < list.length) {
    list.forEach((v) => {
      v.select = false;
    });
    list[i].select = true;
    that.$nextTick(() => {
      that.$refs[`inputfocus${i}`][0].focus();
    });
  }
}

export function requestCode(info, sucMessage, errMessage) {
  // let str =JSON.toString(info)
  if (info.data.code == 0) {
    Message({
      message: sucMessage,
      type: "success",
    });
  } else {
    Message({
      message: errMessage,
      type: "error",
    });
  }
}
